package cn.appsys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.appsys.dao.AppInfoMapper;
import cn.appsys.pojo.AppInfo;
import cn.appsys.service.AppInfoService;

@Service("appInfoService")
public class AppInfoServiceImpl implements AppInfoService {

	@Autowired
	public AppInfoMapper appInfoMapper;

	/**
	 * 显示App信息管理维护
	 */
	public List<AppInfo> list(String flatformName, String categoryLevel1Name, String categoryLevel2Name,
			String categoryLevel3Name, String statusName, String softwareName, int currentPageNo, int pageSize) {
		return appInfoMapper.list(flatformName, categoryLevel1Name, categoryLevel2Name, categoryLevel3Name, statusName,
				softwareName, currentPageNo, pageSize);
	}

	/**
	 * 通过条件查询-开发者表记录数
	 * 
	 * @return
	 */
	public int devUserCount(String flatformName, String categoryLevel1Name, String categoryLevel2Name,
			String categoryLevel3Name, String statusName, String softwareName) {
		return appInfoMapper.devUserCount(flatformName, categoryLevel1Name, categoryLevel2Name, categoryLevel3Name,
				statusName, softwareName);
	}

	/**
	 * 增加App基础信息
	 * 
	 * @param appInfo
	 * @return
	 */
	public int add(AppInfo appInfo) {
		return appInfoMapper.add(appInfo);
	}

	/**
	 * 修改App基础信息
	 * 
	 * @param appInfo
	 * @return
	 */
	public int modify(AppInfo appInfo) {
		return appInfoMapper.modify(appInfo);
	}

	/**
	 * 删除App基础信息
	 * 
	 * @param appInfo
	 * @return
	 */
	public int deleteById(Integer id) {
		return appInfoMapper.deleteById(id);
	}

	/**
	 * 查询APPKName
	 */
	public AppInfo getAppInfo(Integer id, String APKName) {
		return appInfoMapper.getAppInfo(id, APKName);
	}

	/**
	 * App软件上下架
	 */
	public int sale(Integer status, Integer id) {
		return appInfoMapper.sale(status, id);
	}

	/**
	 * 删除文件
	 */
	public int delfile(Integer id, String flag) {
		return appInfoMapper.delfile(id, flag);
	}

	public AppInfo getAppInfo(Integer id) {
		return appInfoMapper.getAppInfo(id, null);
	}

	public boolean updateSatus(Integer status, Integer id) {
		boolean flag = false;
		if(appInfoMapper.updateSatus(status, id) > 0 ){
			flag = true;
		}
		return flag;
	}

	public boolean updateVersionId(Integer versionId, Integer appId) {
		boolean flag = false;
		if(appInfoMapper.updateVersionId(versionId, appId) > 0 ){
			flag = true;
		}
		return flag;
	}
}
